#ifndef GAMESCREEN_H
#define GAMESCREEN_H

#include <QWidget>
#include <QKeyEvent>
#include <QPixmap>
#include <QTimer>
#include "snakegame.h"

class GameScreen : public QWidget
{
    Q_OBJECT

public:
    explicit GameScreen(QWidget *parent = nullptr);
    ~GameScreen();

protected:
    void paintEvent(QPaintEvent *event) override;
    void keyPressEvent(QKeyEvent *event) override;
    void keyReleaseEvent(QKeyEvent *event) override;

private slots:
    void updateGame();

private:
    QPixmap background;
    SnakeGame game;
    QTimer *gameTimer;
    bool gameOver;
    bool speedUp;

    void drawSnake(QPainter &painter);
    void drawFood(QPainter &painter);
    void showGameOver(QPainter &painter);
};

#endif
